filterOrElse

inline fun <L, R> Either<L, R>.filterOrElse(predicate: (R) -> Boolean, zero: () -> L): Either<L, R>?

Returns the same Right if the predicate is satisfied for the value, Left(zero) if the predicate is not satisfied for the value, or the same Left if this is Left.

Return

The same Right if the predicate is satisfied for the value, Left(zero) if the predicate is not satisfied for the value, or the same Left if this is Left.

Since

1.3

Parameters

predicate

Predicate function.

zero

Provider of the value used if the predicate is not satisfied.

inline fun <L, R> LeftProjection<L, R>.filterOrElse(predicate: (L) -> Boolean, zero: () -> R): Either<L, R>?

Returns the same Left if the predicate is satisfied for the value, Right(zero) if the predicate is not satisfied for the value, or the same Right if this is Right.

Return

The same Left if the predicate is satisfied for the value, Right(zero) if the predicate is not satisfied for the value, or the same Right if this is Right.

Since

1.2

Parameters

predicate

Predicate function.

zero

Provider of the value used if the predicate is not satisfied.

inline fun <L, R> RightProjection<L, R>.filterOrElse(predicate: (R) -> Boolean, zero: () -> L): Either<L, R>?

Returns the same Right if the predicate is satisfied for the value, Left(zero) if the predicate is not satisfied for the value, or the same Left if this is Left.

Return

The same Right if the predicate is satisfied for the value, Left(zero) if the predicate is not satisfied for the value, or the same Left if this is Left.

Since

1.2

Parameters

predicate

Predicate function.

zero

Provider of the value used if the predicate is not satisfied.